package com.ys.controller.api.business;

import com.ys.service.business.TpProductBqSpService;
import com.ys.vo.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/api/inter/tpProductBqSp")
public class ApiInterTpProductBqSpController {
    public static Long MENU_ID = 10183L;
    private static final Logger logger = LoggerFactory.getLogger(ApiInterTpProductBqSpController.class);


    @Autowired
    private TpProductBqSpService tpProductBqSpService;


    /**
     * 修改
     */
    @RequestMapping("/toEdit")
    @ResponseBody
    public R toEdit(HttpServletRequest request, @RequestParam Map<String, Object> params, String subData,
    		String materialArr // 商品材质列表，格式：[{"name":"插座","value":161},{"name":"插头","value":160}]
    		) {
        try {
            logger.info("商品备案申请商品修改传参：" + params);
            //修改
            return tpProductBqSpService.update(params, subData);
        } catch (Exception e) {
            logger.error("修改商品备案申请商品出错：", e.getMessage(), e);
            return R.error("系统正在开小差，请联系客服，我们将第一时间为您解决！");
        }
    }

    /**
     * 删除
     */
    @RequestMapping("/del")
    @ResponseBody
    public R del(HttpServletRequest request,@RequestParam("list") List<String> idList,@RequestParam("code") String code){
        try {
            return tpProductBqSpService.del(idList,code);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error("操作失败，请联系客服");
        }
    }
}
